import React, { useEffect, useState } from "react";
import Item from "./Item";
import PubSub from "pubsub-js";
export default function List() {
  const [headerDatum , setHeadDatum] = useState({
    isShow : true,
    underway:false,
    data : []
  })
  useEffect(()  => {
  PubSub.subscribe('github',(_ , data) => {
    setHeadDatum(data)
  })
  })
  return (
    <div>
      <div className="row">
        {
          headerDatum.isShow?(<h2>请开始搜索</h2>):headerDatum.underway?(<h2>正在搜索中</h2>):headerDatum.data.map(item => {
            return <Item key = {item.id} {...item}/>
          })
        }
      </div>
    </div>
  );
}
